
#include "cocos2d.h"
#include "Director/DifficultyFactors/SpawnSets.h"
#include "Levels/CatSpawnSet.h"

#include "config.h"
#include "src/TestMacros.h"
#include "src/CheckMacros.h"
#include "src/TestRunner.h"
#include "src/TimeConstraint.h"
#include "src/ReportAssert.h"

using namespace cocos2d;
using namespace UnitTest;

SUITE(SpawnSets)
{

	TEST(InitalizedZero)
	{
		CCArray* spawnSet = new CCArray();
		SpawnSets* mySpawnSets = new SpawnSets(spawnSet);

		CHECK_EQUAL(mySpawnSets->getNumOfCats(), 0);

		//cleanup
		delete mySpawnSets;
		mySpawnSets = 0;
		spawnSet->release();
		spawnSet = 0;
	}
	TEST(InitalizedTwoUnique)
	{
		// 2 unique cat types
		CCArray* spawnSet = new CCArray();
		spawnSet->addObject(new CatSpawnSet(1,1,1,1));
		spawnSet->addObject(new CatSpawnSet(2,1,1,1));

		SpawnSets* mySpawnSets = new SpawnSets(spawnSet);

		CHECK_EQUAL(mySpawnSets->getNumOfCats(), 2);

		//cleanup
		delete mySpawnSets;
		mySpawnSets = 0;
		CCObject* catSpawnSet = 0;
		CCARRAY_FOREACH(spawnSet, catSpawnSet)
		{
			CatSpawnSet* pSpawnSet = dynamic_cast<CatSpawnSet*>(catSpawnSet);
			delete pSpawnSet;
		}
		spawnSet->release();
		spawnSet = 0;
	}
	TEST(InitalizedOneUnique)
	{
		// 1 unique cat types
		CCArray* spawnSet = new CCArray();
		spawnSet->addObject(new CatSpawnSet(1,1,1,1));
		spawnSet->addObject(new CatSpawnSet(1,1,1,1));

		SpawnSets* mySpawnSets = new SpawnSets(spawnSet);

		CHECK_EQUAL(mySpawnSets->getNumOfCats(), 1);

		//cleanup
		CCObject* catSpawnSet = 0;
		CCARRAY_FOREACH(spawnSet, catSpawnSet)
		{
			CatSpawnSet* pSpawnSet = dynamic_cast<CatSpawnSet*>(catSpawnSet);
			delete pSpawnSet;
		}
		delete mySpawnSets;
		mySpawnSets = 0;
		spawnSet->release();
		spawnSet = 0;
	}

}
